<section class="objectstruct panel rounded">
	<h1><?php printf(lang('title_object_structure'),$object->table); ?></h1>
	
	<div class="table">
		<div class="thead">
			<div class="th name"><?php echo lang('heading_name'); ?></div>
			<div class="th type"><?php echo lang('heading_type'); ?></div>
			<div class="th actions"><?php echo lang('heading_actions'); ?></div>
			<div class="clear"></div>
		</div>
		<div class="tbody">
			<?php foreach ($fields as $field) { ?>
			<form id="row<?php echo $field->object_id.$field->name; ?>" action="api/field/update" method="post" class="row">
					<input type="hidden" name="object_id" value="<?php echo $object->id; ?>" />
					<input type="hidden" name="old_name" value="<?php echo $field->name; ?>" />
					<div class="td name"><input name="new_name" type="text" value="<?php echo $field->name; ?>" /></div>
					<div class="td type">
						<input type="text" name="type" value="<?php echo $field->type; ?>" readonly/>
					</div>
					<div class="td actions">
						<a href="api/field/delete/<?php echo $object->id.'/'.$field->name; ?>"><?php echo lang('action_delete'); ?></a>
						<a href="javascript:void(0);" onClick="$('#row<?php echo $field->object_id.$field->name; ?>').submit();"><?php echo lang('action_update'); ?></a>
					</div>
					<div class="clear"></div>
			</form>
			<?php } ?>
			<form class="new" action="api/field/insert/" method="post">
					<input type="hidden" name="object_id" value="<?php echo $object->id; ?>" />
					<div class="td name">
						<input name="name" type="text"/>
					</div>
					<div class="td type">
						<select name="type">
							<option value="" disabled></option>
						<?php
							foreach (array('integer','decimal','string','i18n_string','color','date','datetime','boolean') as $type) { ?>
							<option value="<?php echo $type; ?>"><?php echo $type; ?></option>
						<?php } ?>
						</select>
					</div>
					<div class="td actions">
						<a href="javascript:void(0);" onClick="$('form.new').submit();"><?php echo lang('action_insert'); ?></a>
					</div>
					<div class="clear"></div>
			</form>
			
		</div>
	
	</div>
</section>